package com.mrjy.schooldiy.controller;

import java.util.HashMap;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.mrjy.common.entity.ActivityInfo;
import com.mrjy.common.entity.DiyArticleInfo;
import com.mrjy.common.entity.DiyNoticeInfo;
import com.mrjy.common.entity.UserInfo;
import com.mrjy.common.enums.ResultEnum;
import com.mrjy.common.util.GlobalConstant;
import com.mrjy.schooldiy.bo.IDiyNoticeBo;
@Controller
@RequestMapping("/schooldiy/notice")
public class DiyNoticeInfoController {
	@Resource
	private IDiyNoticeBo schoolNewsBo;
	/*
	 * 新增 
	 */
	@RequestMapping("/insertDiyNotice")
	@ResponseBody
	public Object insertDiyNotice(DiyNoticeInfo newsInfo,HttpSession session){
		return schoolNewsBo.insertDiyNotice(newsInfo,session);
	}
	/*
	 * 编辑 
	 */
	@RequestMapping("/updateDiyNotice")
	@ResponseBody
	public Object updateDiyNotice(DiyNoticeInfo newsInfo,HttpSession session){
		return schoolNewsBo.updateDiyNotice(newsInfo,session);
	}
	
	/*
	 * 禁用、起用
	 * @param ids
	 * @return
	 */
	@RequestMapping("/updateDisableFlag")
	@ResponseBody
	public Object updateDisableFlag(DiyNoticeInfo newsInfo,HttpSession session) {	
		UserInfo loginUser = (UserInfo) session.getAttribute(GlobalConstant.USER_INFO);
		HashMap<String, Object> map = new HashMap<String, Object>();
		if(null == loginUser ){
			map.put("err_msg", ResultEnum.NOT_LOGIN);
			return map;
		}
		if (null == newsInfo.getIds()) {
			map.put("err_msg", ResultEnum.PARAM_ERROR);
			return map;
		}
		return schoolNewsBo.txUpdateDisableFlag(newsInfo);
    }
	/*
	 *Pc分页查询 
	 */
	@RequestMapping("/queryPageForPc")
	@ResponseBody
	public Object queryPageForPc(DiyNoticeInfo newsInfo,HttpSession session) {	
		return schoolNewsBo.queryPageForPc(newsInfo,session);
    }
	/*
	 * 微信端查询所有通知
	 * */
	@RequestMapping("/queryPageList")
	@ResponseBody
	public Object queryPageList(DiyNoticeInfo newsInfo,HttpSession session) {	
		return schoolNewsBo.queryPageList(newsInfo,session);
    }
	/*
	 *微信端根据 id查询通知详情
	 *
	 * */
	@RequestMapping("/queryDiyNoticeByid")
	@ResponseBody
	public Object queryDiyNoticeByid(DiyNoticeInfo newsInfo,HttpSession session) {	
		return schoolNewsBo.queryDiyNoticeByid(newsInfo,session);
    }
	
	/*
	 *微信端通知信息浏览量+1
	 */
	@RequestMapping("/addNoticeViewNum")
	@ResponseBody
	public Object addNoticeViewNum(DiyNoticeInfo newsInfo,HttpSession session) {	
		return schoolNewsBo.addNoticeViewNum(newsInfo,session);
    }
}
